<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="./script/rem.js"></script>
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>

    <script type="text/javascript" src="./script/api.js"></script>
    <script type="text/javascript" src="./script/aui-sharebox.js" ></script>
    <script type="text/javascript" src="./script/aui-tab.js" ></script>
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <script type="text/javascript" src="./script/aui-slide.js"></script>

    <script type="text/javascript" src="./script/base.js"></script>

</head>

<body>

    <!-- <header class="head" style="padding-top:0.4rem;">
    <div class="head-l" tapmode onclick="closeWin()"><i class="fa fa-angle-left"></i></div>
    <h3>关于我们</h3>
</header> -->

<div class="foot-bg">
    <div class="foot-top"></div>
    <div class="foot">
        <ul>
            <li>
              <div class="foot-m">
                <img src="image/foot-m.png">
                <ul class="foot-share">
                  <li><img src="image/foot-share-1.png"></li>
                  <li><img src="image/foot-share-2.png"></li>
                  <li><img src="image/foot-share-3.png"></li>
                  <li><img src="image/foot-share-4.png"></li>
              </ul>
          </div>
      </li>
  </ul>
  <div class="foot-m"></div>
</div>
<div class="foot-d" style="height:0"></div>
</div>
<div class="body-bg">
</div>

</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript" src="./script/index.js"></script>
<script type="text/javascript">
    var ajpush = null;
    apiready = function() {

        // dark：黑色 light：白色
        api.setStatusBarStyle({
            style: 'light'
        });

        api.setAppIconBadge({
            badge: 0
        });

        ajpush = api.require('ajpush');

        ajpush.init(function(ret) {
            // alert( JSON.stringify( ret ) );
            if (ret && ret.status){

                ajpush.getRegistrationId(function(ret) {
                    var registrationId = ret.id;
                    // alert(registrationId);
                    $api.setStorage('registrationId', registrationId);
                });

                // 安卓点击通知处理事件 监听
                api.addEventListener({
                    name: 'appintent'
                }, function(ret, err) {
                    // alert( JSON.stringify( ret ) );
                    if (ret && ret.appParam.ajpush) {
                        var ajpush = ret.appParam.ajpush;
                        var id = ajpush.id;
                        var title = ajpush.title;
                        var content = ajpush.content;
                        var extra = ajpush.extra;

                        ajpush.setBadge({
                            badge:0
                        });

                        var category = extra.data.data.category;
                        if (category == 10) {

                            // 我的零售下单：跳转到个人中心-我的零售页面
                            api.openWin({
                                name: 'order_manage',
                                url: './order_manage.html',
                                pageParam: {
                                  name: 'test'
                              }
                          });
                        }else if(category == 11){
                            // alert('待发货')
                            // 商城已发货：跳转到待收货列表
                            api.openWin({
                                name: 'order',
                                url: './order.html',
                                pageParam: {
                                  type: 3
                              }
                          });

                        }else if(category == 20){

                            // mvp到期（到期提前一天提醒）：跳转到MVP页
                            api.openWin({
                                name: 'user_level',
                                url: './user_level.html',
                                pageParam: {
                                  name: 'test'
                              }
                          });
                        }else if(category == 30){

                            // 通知：跳转到通知栏目
                            api.openWin({
                                name: 'notice',
                                url: './notice.html',
                            });
                        }else if(category == 40){

                            // 需权限审批：跳转到权限审批
                            $api.setStorage('uplevel_apply', 1);
                            api.openWin({
                                name: 'uplevel_apply',
                                url: './uplevel_apply.html',
                            });
                        }else if(category == 41){
                            // 被升级成功：跳转到个人中心并刷新
                            var NVTabBar = api.require('NVTabBar');
                            api.setFrameGroupIndex({
                                name: 'nav',
                                index: 3,
                                reload: true,
                            });
                            NVTabBar.setSelect({
                                index: 4,
                                selected: true,
                            });
                            NVTabBar.bringToFront();
                            api.closeToWin({
                                name: 'root'
                            });
                        }else if(category == 42){

                            // 充值赚石成功：跳转个人中心并刷新
                            var NVTabBar = api.require('NVTabBar');
                            api.setFrameGroupIndex({
                                name: 'nav',
                                index: 3,
                                reload: true,
                            });
                            NVTabBar.setSelect({
                                index: 4,
                                selected: true,
                            });
                            NVTabBar.bringToFront();
                            api.closeToWin({
                                name: 'root'
                            });
                        }
                    }
                });

                // iOS点击通知处理事件 监听
                api.addEventListener({
                    name: 'noticeclicked'
                }, function(ret, err) {
                    // alert( JSON.stringify( ret ) );
                    if (ret && ret.value) {
                        var ajpush = ret.value;
                        var content = ajpush.content;
                        var extra = ajpush.extra;

                        ajpush.setBadge({
                            badge:0
                        });

                        var category = extra.data.data.category;
                        if (category == 10) {

                            // 我的零售下单：跳转到个人中心-我的零售页面
                            api.openWin({
                                name: 'order_manage',
                                url: './order_manage.html',
                                pageParam: {
                                  name: 'test'
                              }
                          });
                        }else if(category == 11){
                            // 商城已发货：跳转到待收货列表
                            api.openWin({
                                name: 'order',
                                url: './order.html',
                                pageParam: {
                                  type: 3
                              }
                          });

                        }else if(category == 20){

                            // mvp到期（到期提前一天提醒）：跳转到MVP页
                            api.openWin({
                                name: 'user_level',
                                url: './user_level.html',
                                pageParam: {
                                  name: 'test'
                              }
                          });
                        }else if(category == 30){

                            // 通知：跳转到通知栏目
                            api.openWin({
                                name: 'notice',
                                url: './notice.html',
                            });
                        }else if(category == 40){

                            // 需权限审批：跳转到权限审批
                            $api.setStorage('uplevel_apply', 1);
                            api.openWin({
                                name: 'uplevel_apply',
                                url: './uplevel_apply.html',
                            });
                        }else if(category == 41){
                            // 被升级成功：跳转到个人中心并刷新
                            var NVTabBar = api.require('NVTabBar');
                            api.setFrameGroupIndex({
                                name: 'nav',
                                index: 3,
                                reload: true,
                            });
                            NVTabBar.setSelect({
                                index: 4,
                                selected: true,
                            });
                            NVTabBar.bringToFront();
                            api.closeToWin({
                                name: 'root'
                            });
                        }else if(category == 42){

                            // 充值赚石成功：跳转个人中心并刷新
                            var NVTabBar = api.require('NVTabBar');
                            api.setFrameGroupIndex({
                                name: 'nav',
                                index: 3,
                                reload: true,
                            });
                            NVTabBar.setSelect({
                                index: 4,
                                selected: true,
                            });
                            NVTabBar.bringToFront();
                            api.closeToWin({
                                name: 'root'
                            });
                        }
                    }
                });

            }
        });



api.addEventListener({
    name:'viewappear'
}, function(ret, err){
    api.setScreenOrientation({
        orientation: 'portrait_up'
    });
});

tabBer();

        // 判断登录token时效性
        var token = $api.getStorage('token');
        if (token) {
            api.ajax({
              url: webAddress + '/api/auth/info',
              method: 'get',
              data: {
                values: {
                },
            },
            headers: {
                Authorization: 'Bearer ' + token,
                Accept: 'application/json',
            },
        },function(ret, err){
          if (ret) {
            // alert( JSON.stringify( ret ) );

        } else {
            // alert( JSON.stringify( err ) );

            if (err.body.status_code == 401) {

                api.toast({
                    msg: '登录失效,请重新登录!',
                    duration: 2000,
                    location: 'bottom',
                    global: true,
                });

                api.openWin({
                    name: 'login',
                    url: './login.html',
                    pageParam: {
                        name: 'test'
                    }
                });
                return false;
            }
        }
    });
        }

    }


    function tabBer() {
        NVTabBar = api.require('NVTabBar');
        NVTabBar.open({
            styles: {
                bg: '#ffffff',
                    //bg:"widget://image/NVTabBar/tabbar_bg.png",
                    h: 50,
                    dividingLine: {
                        width: 0,
                        color: '#000'
                    },
                    badge: {
                        bgColor: '#fff',
                        numColor: '#fff',
                        size: 6.0,
                        centerX: 40,
                        centerY: 6
                    }
                },
                items: [{
                    w: api.winWidth / 5.0,
                    bg: {
                        marginB: 0,
                        // image: 'rgba(200,200,200,0.6)'
                    },
                    iconRect: {
                        w: 25.0,
                        h: 25.0,
                    },
                    icon: {
                        normal: 'widget://image/foot-1.png',
                        highlight: 'widget://image/foot-1.png',
                        selected: 'widget://image/foot-1.png'
                    },
                    title: {
                        text: '首页',
                        size: 12.0,
                        normal: '#696969',
                        selected: '#eb4f38',
                        marginB: 6.0
                    }
                }, {
                    w: api.winWidth / 5.0,
                    bg: {
                        marginB: 0,
                        // image: 'rgba(200,200,200,0.7)'
                    },
                    iconRect: {
                        w: 25.0,
                        h: 25.0,
                    },
                    icon: {
                        normal: 'widget://image/foot-2.png',
                        highlight: 'widget://image/foot-2.png',
                        selected: 'widget://image/foot-2.png'
                    },
                    title: {
                        text: '商城',
                        size: 12.0,
                        normal: '#696969',
                        selected: '#eb4f38',
                        marginB: 6.0
                    }
                }, {
                    w: api.winWidth / 5.0,
                    bg: {
                        marginB: 0,
                        // image: 'widget://images/foot-5.png' //中间背景图
                    },
                    iconRect: {
                        w: 45,
                        h: 45,

                    },
                    icon: {
                        normal: 'widget://image/foot-m.png',
                        highlight: 'widget://image/foot-m.png',
                        selected: 'widget://image/foot-m.png'
                    },
                    title: {
                        //text : '333',
                        // size: 0.0,
                        // normal: '#696969',
                        // selected: '#eb4f38',
                        // marginB: 0
                    }
                }, {
                    w: api.winWidth / 5.0,
                    bg: {
                        marginB: 0,
                        // image: 'rgba(200,20,0,0.6)'
                    },
                    iconRect: {
                        w: 25.0,
                        h: 25.0,
                    },
                    icon: {
                        normal: 'widget://image/foot-3.png',
                        highlight: 'widget://image/foot-3.png',
                        selected: 'widget://image/foot-3.png'
                    },
                    title: {
                        text: '发现',
                        size: 12.0,
                        normal: '#696969',
                        selected: '#eb4f38',
                        marginB: 6.0
                    }
                }, {
                    w: api.winWidth / 5.0,
                    bg: {
                        marginB: 0,
                        // image: 'rgba(220,0,220,0.7)'
                    },
                    iconRect: {
                        w: 25.0,
                        h: 25.0,
                    },
                    icon: {
                        normal: 'widget://image/foot-4.png',
                        highlight: 'widget://image/foot-4.png',
                        selected: 'widget://image/foot-4.png',
                    },
                    title: {
                        text: '我的',
                        size: 12.0,
                        normal: '#696969',
                        selected: '#eb4f38',
                        marginB: 6.0
                    }
                }],
                selectedIndex: 0
            }, function(ret, err) {
                // alert( JSON.stringify( ret ) );
                openframe();
                if (ret.index==3) {
                    api.setFrameGroupIndex({
                        name: 'nav',
                        index: 2,
                        reload: true,
                    });
                    NVTabBar.bringToFront();
                    return;
                }else if(ret.index == 4){
                    // 判断是否登录
                    var token = $api.getStorage('token');
                    if (!token) {
                        api.openWin({
                            name: 'login',
                            url: './login.html',
                            pageParam: {
                                // type: 'frameGroup',
                                // name: 'nav',
                                // index: ret.index,
                                backUrl: 'userindex'
                            }
                        });
                        NVTabBar.bringToFront();
                    }else{
                        api.setFrameGroupIndex({
                            name: 'nav',
                            index: 3,
                            reload: true,
                        });
                        NVTabBar.bringToFront();
                        return;
                    }
                }else if(ret.index == 2){
                    openShareFrame();
                }else{

                    api.setFrameGroupIndex({
                        name: 'nav',
                        index: ret.index,
                        reload: true,
                    });
                    NVTabBar.bringToFront();
                }
            });
}

    // 打开分享控件
    function openShareUI(){
        demo = api.require('arcMenu');
        demo.open({
            type : 'arc',
            mainMenu : {
                x : api.frameWidth / 2,
                y : api.frameHeight-40,
                w : 50,
                h : 50,
                img : '',
                imgLight : ''
            },
            items : [{
                w : 40,
                h : 40,
                img : 'widget://image/foot-share-1.png',
                imgLight : 'widget://image/foot-share-1.png'
            }, {
                w : 40,
                h : 40,
                img : 'widget://image/foot-share-1.png',
                imgLight : 'widget://image/foot-share-1.png'
            }, {
                w : 40,
                h : 40,
                img : 'widget://image/foot-share-1.png',
                imgLight : 'widget://image/foot-share-1.png'
            }, {
                w : 40,
                h : 40,
                img : 'widget://image/foot-share-2.png',
                imgLight : 'widget://image/foot-share-1.png'
            }],
            startAngle : 275,
            wholeAngle : 180,
            radius : 100,
            fixedOn : api.frameName,
        }, function(ret, err) {
            if (ret) {
                // alert(JSON.stringify(ret));
                id = ret.id;
            } else {
                // alert(JSON.stringify(err));
            }
        });
    }

    // 打开分享frame
    function openShareFrame(){
        var w = api.winWidth;
        var h = api.winHeight-50;
        api.openFrame({
            name: 'share',
            url: './arcmenu.html',
            rect: {
                x: 0,
                y: 0,
                w: w,
                h: h,
            },
            pageParam: {
                name: 'test'
            },
            bounces: false,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: true,
            hScrollBarEnabled: true
        });
        NVTabBar.bringToFront();
    }

    // 创建frame组
    function openframe() {
        api.openFrameGroup({
            name: 'nav',
            scrollEnabled: false,
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                marginBottom: 50
            },
            frames: [{
                name: 'index',
                url: './index.html',
                bgColor: '#fff'
            }, {
                name: 'shop',
                url: './shop.html',
                bgColor: '#fff'
            },{
                name: 'find_index',
                url: './find_index.html',
                bgColor: '#fff'
            }, {
                name: 'user_index',
                url: './user_index.html',
                bgColor: '#fff'
            }]
        }, function(ret, err) {
            // openShareUI();
        });
    }

    // 退出登陆后跳转首页
    function gotoIndex(){

        api.closeToWin({
            name: 'root'
        });

        var NVTabBar = api.require('NVTabBar');
        api.setFrameGroupIndex({
            name: 'nav',
            index: 0,
            reload: true,
        });
        NVTabBar.setSelect({
            index: 0,
            selected: true,
        });
        NVTabBar.bringToFront();
    }

    // 登录成功会跳转到用户首页
    function gotoUserIndex(){
        var NVTabBar = api.require('NVTabBar');
        api.setFrameGroupIndex({
            name: 'nav',
            index: 3,
            reload: true,
        });
        NVTabBar.setSelect({
            index: 4,
            selected: true,
        });
        NVTabBar.bringToFront();
    }

    // 跳转商城分类
    function gotoShop(){
        var NVTabBar = api.require('NVTabBar');
        api.setFrameGroupIndex({
            name: 'nav',
            index: 1,
            reload: true,
        });
        NVTabBar.setSelect({
            index: 1,
            selected: true,
        });
        NVTabBar.bringToFront();
    }

    // 跳转快抖云
    function gotoKDY(){

        $api.setStorage('KDY', 1);

        var NVTabBar = api.require('NVTabBar');
        api.setFrameGroupIndex({
            name: 'nav',
            index: 2,
            reload: true,
        });
        NVTabBar.setSelect({
            index: 3,
            selected: true,
        });
        NVTabBar.bringToFront();
    }


    // 注册成功后跳转首页
    function registerGotoIndex(){

        api.toast({
            msg: '注册成功!',
            duration: 2000,
            location: 'bottom',
            global: true,
        });

        api.closeToWin({
            name: 'root'
        });

        var NVTabBar = api.require('NVTabBar');
        api.setFrameGroupIndex({
            name: 'nav',
            index: 0,
            reload: true,
        });
        NVTabBar.setSelect({
            index: 0,
            selected: true,
        });
        NVTabBar.bringToFront();
    }


    function toHome() {
      api.closeToWin({
        name: 'root'
    });

  }

    // 首页下拉刷新
    function refreshIndex(){
        var NVTabBar = api.require('NVTabBar');
        api.setFrameGroupIndex({
            name: 'nav',
            index: 0,
            reload: true,
        });
        NVTabBar.setSelect({
            index: 0,
            selected: true,
        });
        NVTabBar.bringToFront();
    }


    // 小游戏返回后续逻辑
    function quitGame(){

        api.confirm({
            title: '提示',
            msg: '是否退出?',
            buttons: ['确定', '取消']
        }, function(ret, err){
            if( ret ){
                // alert( JSON.stringify( ret ) );
                if (ret.buttonIndex == 1) {

                    api.setScreenOrientation({
                        orientation: 'portrait_up'
                    });

                    api.closeToWin({
                        name: 'root'
                    });
                }
            }else{
         // alert( JSON.stringify( err ) );
     }
 });



    }

    // 小游戏调用分享
    function shareGame(url){

        // api.execScript({
        //     name: 'game',
        //     frameName: 'gameFrame',
        //     script: 'shareGame();'
        // });


        // var jsfun = 'shareGame('+content+','+url+','+imgUrl+','+title+');';
        // api.execScript({
        //     name: 'game',
        //     script: jsfun
        // });

        // var sharedModule = api.require('shareAction');
        // sharedModule.share({
        //     text: '分享测试',
        //     type: 'url',
        //     path: url,
        //     thumbnail: 'widget://image/find-school-add.png'
        // });
    }

    // 小游戏竖屏方法
    function openPortraitWinGame(){
        api.setScreenOrientation({
            orientation: 'portrait_up'
        });
    }

    // 小游戏横屏方法
    function openLandscapeWinGame(){

        api.setScreenOrientation({
            orientation: 'landscape_left'
        });

    }

    // 小游戏打开加载动画
    function openLoadingGame(){

        // alert(222)
        var close_loading = 'openLoadingGame();';
        api.execScript({
            name: 'game',
            script: close_loading
        });

        // timer = setTimeout(function(){    

        //     api.showProgress({
        //         style: 'default',
        //         animationType: 'fade',
        //         title: '正在努力加载中...',
        //         modal: false
        //     });

        // },888);
    }

    // 小游戏关闭加载动画
    function closeLoadingGame(){

        var close_loading = 'closeLoadingGame();';
        api.execScript({
            name: 'game',
            script: close_loading
        });
    }

    // 小游戏跳转兑换页面
    function gotoGiftExchangeGame(){
        api.setScreenOrientation({
            orientation: 'portrait_up'
        });

        api.openWin({
            name: 'special',
            url: './special.html',
            pageParam: {
                id: 5,
                title: '兑换商城',
            }
        });
    }

    // 小游戏下注
    // function chipGame(url){

    //     api.setScreenOrientation({
    //         orientation: 'portrait_up'
    //     });

    //     api.openWin({
    //         name: 'chip',
    //         url: './game_chip.html',
    //         pageParam: {
    //             url: url
    //         },
    //         slidBackEnabled: false,
    //         animation: false,
    //     });
    // }

    // // 关闭所有页面 并且返回首页
    // function closeAllWinGame(){

    //     api.setScreenOrientation({
    //         orientation: 'landscape_left'
    //     });

    //     api.closeToWin({
    //         name: 'game'
    //     });

    // }

    // // 小游戏打开横屏页面
    // function landscapeGame(url){

    //     // alert(url);

    //     api.setScreenOrientation({
    //         orientation: 'landscape_left'
    //     });

    //     api.openWin({
    //         name: url,
    //         url: url,
    //         pageParam: {
    //             name: 'test'
    //         },
    //         reload: true,
    //         slidBackEnabled: false,
    //         animation: false,
    //     });
    // }

    // // 小游戏打开竖屏页面
    // function portraitUpGame(url){

    //     api.setScreenOrientation({
    //         orientation: 'portrait_up'
    //     });

    //     api.openWin({
    //         name: url,
    //         url: url,
    //         pageParam: {
    //             name: 'test'
    //         },
    //         reload: true,
    //         slidBackEnabled: false,
    //         animation: false,
    //     });
    // }

    // // 小游戏关闭当前页面并且横屏
    // function closeCurWinLandscapeGame(){

    //     api.setScreenOrientation({
    //         orientation: 'landscape_left'
    //     });

    //     api.closeWin();

    // }

    // // 小游戏关闭当前页面并且竖屏
    // function closeCurWinPortraitGame(){

    //     api.setScreenOrientation({
    //         orientation: 'portrait_up'
    //     });

    //     api.closeWin();

    // }

    function closeWin() {
        api.closeWin({});
    }
</script>

</html>
